﻿using MomentumPlugin.Common;
using Plugins;
using StockModel;

namespace MomentumPlugin.Historical
{
	internal class HistoricalEngine : Plugins.Base.Historical.HistoricalEngineBase
	{
		#region Attributes

		private readonly DecisionEngineData _decisionEngineData;

		private DecisionEngine _decisionEngine;

		#endregion

		#region Properties

		public new HistoricalSettings Settings
		{
			get
			{
				return (HistoricalSettings)base.Settings;
			}
			set
			{
				base.Settings = value;
			}
		}

		#endregion

		#region Public Methods

		public HistoricalEngine(QuotationDataSource quotationDataSource, RawStockDataSource rawStockDataSource, DecisionEngineData decisionEngineData) : base(quotationDataSource, rawStockDataSource)
		{
			_decisionEngineData = decisionEngineData;
		}

		protected override void InitializeEngine()
		{
			base.InitializeEngine();

			_decisionEngine = new DecisionEngine(_decisionEngineData, base.DataFeeder.Data, this.Settings.StrategyControlData, this.Settings.HourOptions, base.OperationManager);
		}

		protected override void ProcessHistoricalItem(HistoricalItemToProcess item)
		{
			base.OperationManager.StockSymbol = item.Stock.Id.Code;
			base.DataLoader.Data.Clear();
			base.DataLoader.Load(item.Date, item.Stock);
		}

		#endregion
	}
}
